/*
 * DAOC-TB - Tools for DAoC-Player
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 *
 *  CDlgRespec.cpp
 */


#include "stdafx.h"
#include "Charplan.h"
#include "CDlgRespec.h"
#include ".\cdlgrespec.h"


// CDlgRespec-Dialogfeld

IMPLEMENT_DYNAMIC(CDlgRespec, CDialog)
CDlgRespec::CDlgRespec(CWnd* pParent /*=NULL*/)
        : CDialog(CDlgRespec::IDD, pParent)
        , mn_type(1)
        , mn_level(40)

{

}

CDlgRespec::~CDlgRespec()
{
}

void CDlgRespec::DoDataExchange(CDataExchange* pDX)
{
    CDialog::DoDataExchange(pDX);
    DDX_Control(pDX, IDC_LIST1, mwnd_lines);
    DDX_Radio(pDX, IDC_RADIO1, mn_type);
    DDX_Control(pDX, IDC_WARNING, mwnd_warning);
}


BEGIN_MESSAGE_MAP(CDlgRespec, CDialog)
    ON_BN_CLICKED(IDC_RADIO1, OnBnClickedRadio1)
    ON_BN_CLICKED(IDC_RADIO2, OnBnClickedRadio2)
    ON_BN_CLICKED(IDOK, OnBnClickedOk)
END_MESSAGE_MAP()


// CDlgRespec-Meldungshandler
BOOL CDlgRespec::OnInitDialog()
{
    CDialog::OnInitDialog();

    // helping vars
    CStringArray result_lines;

    // Styles
    gdbinterface.GetListOfStyleLines(result_lines);
    for (int t=0;t<result_lines.GetCount();t++)
    {
        mwnd_lines.AddString(result_lines[t]);
    }

    // Spells
    gdbinterface.GetListOfSpellLines(result_lines);
    for (int t=0;t<result_lines.GetCount();t++)
    {
        gdbinterface.SelectSpellLine(result_lines[t]);

        CString name = gdbinterface.GetSpellLineNameBase();
//  if (gdbinterface.GetSkillName() != name)
//   name.Format("%s (%s)",gdbinterface.GetSkillName(),gdbinterface.GetSpellLineNameBase());

        mwnd_lines.AddString(name);
    }

    // select first
    mwnd_lines.SetCurSel(0);


    // warning
    if (mn_level != 20 && mn_level != 40)
        mwnd_warning.ShowWindow(SW_SHOW);


    return TRUE;
}


void CDlgRespec::OnBnClickedRadio1()
{
    UpdateData(TRUE);
    mwnd_lines.EnableWindow(mn_type == 1);
}

void CDlgRespec::OnBnClickedRadio2()
{
    UpdateData(TRUE);
    mwnd_lines.EnableWindow(mn_type == 1);
}


CString CDlgRespec::GetRespecLine()
{
    return mstr_cur_sel;
}


void CDlgRespec::OnBnClickedOk()
{
    if (mn_type == 0) mstr_cur_sel.Empty();
    else
    {
        int idx = mwnd_lines.GetCurSel();
        ASSERT(idx != LB_ERR);
        mwnd_lines.GetText(idx,mstr_cur_sel);
    }

    OnOK();
}
